package com.mmd.utils;//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.math.BigDecimal;
import java.util.Collection;
import java.util.Enumeration;
import java.util.Iterator;
import java.util.Map;

public final class Validator {
    private static final Logger log = LoggerFactory.getLogger(Validator.class);

    private Validator() {
    }

    public static final boolean isNullOrEmpty(Object value) {
        if (null == value) {
            return true;
        } else {
            boolean flag = false;
            if (value instanceof Collection) {
                flag = ((Collection)value).isEmpty();
            } else if (value instanceof Map) {
                flag = ((Map)value).isEmpty();
            } else if (value instanceof Object[]) {
                flag = ((Object[])((Object[])value)).length == 0;
            } else if (value instanceof String) {
                flag = value.toString().trim().length() <= 0;
            } else if (value instanceof Enumeration) {
                flag = !((Enumeration)value).hasMoreElements();
            } else if (value instanceof Iterator) {
                flag = !((Iterator)value).hasNext();
            }

            return flag;
        }
    }

    public static final boolean isNotNullOrEmpty(Object value) {
        return !isNullOrEmpty(value);
    }

    /** @deprecated */
    public static final boolean isNull(Object value) {
        return isNullOrEmpty(value);
    }

    /** @deprecated */
    public static final boolean isNotNull(Object value) {
        return isNotNullOrEmpty(value);
    }

    public static final boolean isSpecificNumber(Object value, String specificNumber) {
        boolean flag = false;
        if (isNotNullOrEmpty(value)) {
            String valueString = value.toString();
            if (value instanceof Number || value instanceof String) {
                BigDecimal bigDecimal = new BigDecimal(valueString);
                int i = bigDecimal.compareTo(new BigDecimal(specificNumber));
                flag = i == 0;
            }
        }

        if (!flag) {
        }

        return flag;
    }
}
